<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>连续整数求和</title>
</head>
<body>
  <script>
    function fm(n, k) {
      if (k % 2 == 1) {
        return n % k == 0;
      }
      else {
        return n % k != 0 && 2 * n % k == 0;
      }
    }
    function fn(n) {
      let res = 0;
      let k = 1;
      while (k * (1 + k) / 2 <= n) {
        if (fm(n, k) == true) {
          res++;
        }
        k++;
      }
      return res;
    }
    console.log(fn(5))
  </script>
</body>
</html>